#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <time.h>
using namespace std;

void Chuyen(int, char, char, char);

int main (int argc, const char * argv[])
{
    int n = 11;
	float runningTime = 0;
	FILE *p = NULL;
	char *file = "ThapHaNoiDataForCharting.csv";

	p = fopen(file,"w");

	if(p==NULL)
	{
		printf("File not found...\n");
	}
	fprintf(p,"N;T\n");
	//printf("\n<<%d>>\n",n);


	for(int i = 3; i <= 20; i++)
	{
		//printf("\n\nNhap so dia: ");
		//scanf("%d", &n);

		n = i;
		fprintf(p,"%d;",n);
		printf("%d\nCac buoc chuyen dia:", n);

		clock_t start = clock();		
		Chuyen(n, 'A', 'B', 'C');
		runningTime = ((double)clock() - start)/ CLOCKS_PER_SEC;
		
		fprintf(p,"%f\n",runningTime);
		printf("\n\n%d Pieces\nTime elapsed: %f\n\n", n, runningTime);

		
		//getch();
	}
	fclose(p);

}

void Chuyen(int n, char cotA, char cotC, char cotB)
{
    if(n == 1)
    {
        printf("\nChuyen dia 1 tu cot %c den cot %c", cotA, cotC);
        return;
    }
    Chuyen(n-1, cotA, cotB, cotC);
    printf("\nChuyen dia %d tu cot %c den cot %c", n, cotA, cotC);
    Chuyen(n-1, cotB, cotC, cotA);

	
}